

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>ALASpy.las &mdash; ALASpy 0.1.1 documentation</title>
    
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '0.1.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/sidebar.js"></script>
    <link rel="top" title="ALASpy 0.1.1 documentation" href="../../index.html" />
    <link rel="up" title="Module code" href="../index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../index.html">ALASpy 0.1.1 documentation</a> &raquo;</li>
          <li><a href="../index.html" accesskey="U">Module code</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <h1>Source code for ALASpy.las</h1><div class="highlight"><pre>
<span class="c"># -*- coding: utf-8 -*-</span>
<span class="sd">&quot;&quot;&quot; The LAS Object module.</span>

<span class="sd">Read and write LAS files</span>

<span class="sd">  :Author:</span>
<span class="sd">    - 2010-2012 Nicola Creati and Roberto Vidmar</span>

<span class="sd">  :Revision:  $Revision: 6 $</span>
<span class="sd">              $Date: 2012-12-27 11:24:41 +0100 (Thu, 27 Dec 2012) $</span>

<span class="sd">  :Copyright: 2010-2012</span>
<span class="sd">              Nicola Creati &lt;ncreati@inogs.it&gt;</span>
<span class="sd">              Roberto Vidmar &lt;rvidmar@inogs.it&gt;</span>

<span class="sd">  :License: MIT/X11 License (see :download:`LICENSE.txt</span>
<span class="sd">                             &lt;../../LICENSE.txt&gt;`)</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="c">#===============================================================================</span>
<span class="kn">import</span> <span class="nn">os</span>

<span class="c"># Local libraries</span>
<span class="kn">from</span> <span class="nn">header</span> <span class="kn">import</span> <span class="n">Header</span><span class="p">,</span> <span class="n">getLongest</span>
<span class="kn">from</span> <span class="nn">pointDataRecords</span> <span class="kn">import</span> <span class="n">PointDataRecords</span>
<span class="kn">from</span> <span class="nn">lasExceptions</span> <span class="kn">import</span> <span class="n">LasException</span>

<span class="c">#===============================================================================</span>
<div class="viewcode-block" id="LasObject"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject">[docs]</a><span class="k">class</span> <span class="nc">LasObject</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; The LAS file class</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="c"># Keep trace of opened files</span>
  <span class="n">_lock</span> <span class="o">=</span> <span class="p">[]</span>

<div class="viewcode-block" id="LasObject.__init__"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.__init__">[docs]</a>  <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s">&#39;r&#39;</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Create a new :class:`LasObject` instance.</span>

<span class="sd">      :param filename: LAS file to open</span>
<span class="sd">      :type filename: unicode</span>
<span class="sd">      :param mode: file mode (&#39;r&#39; or &#39;w&#39;)</span>
<span class="sd">      :type mode: string</span>

<span class="sd">      Optional kargs will be passed to Header</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_filename</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>

    <span class="c"># Check if file is already opened</span>
    <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lock</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">f</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_filename</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span>
          <span class="s">&quot;File </span><span class="si">%s</span><span class="s"> is already in use. Close the file or delete &quot;</span>
          <span class="s">&quot;the reference to it&quot;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_filename</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_lock</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_filename</span><span class="p">)</span>

    <span class="c"># Now open the file</span>
    <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s">&#39;w&#39;</span><span class="p">:</span>
      <span class="c"># Write mode:  Binary mode must be explicitly set on Window</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_fid</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_filename</span><span class="p">,</span> <span class="s">&#39;wb&#39;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="c"># Read mode: Binary mode must be explicitly set on Window</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_fid</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_filename</span><span class="p">,</span> <span class="s">&#39;rb&#39;</span><span class="p">)</span>

    <span class="bp">self</span><span class="o">.</span><span class="n">_header</span> <span class="o">=</span> <span class="n">Header</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_PointDataRecords</span> <span class="o">=</span> <span class="n">PointDataRecords</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="LasObject.__repr__"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.__repr__">[docs]</a>  <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return string representation of the :class:`LasObject`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">title</span> <span class="o">=</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s">:</span><span class="se">\n</span><span class="s">  Filename: </span><span class="si">%s</span><span class="se">\n</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="o">.</span><span class="n">__name__</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_filename</span><span class="p">)</span>
    <span class="n">headerRepr</span> <span class="o">=</span> <span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="p">)</span> <span class="o">+</span> <span class="s">&#39;</span><span class="se">\n</span><span class="s">&#39;</span>
    <span class="n">vlrRepr</span> <span class="o">=</span> <span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="nb">repr</span><span class="p">(</span><span class="n">vlr</span><span class="p">)</span> <span class="k">for</span> <span class="n">vlr</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">varLengthRecords</span><span class="p">()])</span>
    <span class="n">lenmax</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">getLongest</span><span class="p">(</span><span class="n">headerRepr</span><span class="p">),</span> <span class="n">getLongest</span><span class="p">(</span><span class="n">vlrRepr</span><span class="p">))</span>
    <span class="n">title</span> <span class="o">+=</span> <span class="s">&#39;-&#39;</span> <span class="o">*</span> <span class="p">(</span><span class="n">lenmax</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span> <span class="o">+</span> <span class="s">&#39;</span><span class="se">\n</span><span class="s">&#39;</span>
    <span class="k">return</span> <span class="n">title</span> <span class="o">+</span> <span class="n">headerRepr</span> <span class="o">+</span> <span class="n">vlrRepr</span>

<span class="c">#-------------------------------------------------------------------------------</span>
<span class="c"># Public methods</span>
<span class="c">#-------------------------------------------------------------------------------</span></div>
<div class="viewcode-block" id="LasObject.fid"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.fid">[docs]</a>  <span class="k">def</span> <span class="nf">fid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return LAS file identifier</span>

<span class="sd">      :returns: LAS file identifier</span>
<span class="sd">      :rtype: :class:`file`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fid</span>
</div>
<div class="viewcode-block" id="LasObject.bbox"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.bbox">[docs]</a>  <span class="k">def</span> <span class="nf">bbox</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return bounding box [xmin, xmax, ymin, ymax, zmin, zmax]</span>

<span class="sd">      :returns: bounding box [xmin, xmax, ymin, ymax, zmin, zmax]</span>
<span class="sd">      :rtype: tuple</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="p">(</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getXmin</span><span class="p">(),</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getXmax</span><span class="p">(),</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getYmin</span><span class="p">(),</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getYmax</span><span class="p">(),</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getZmin</span><span class="p">(),</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getZmax</span><span class="p">())</span>
</div>
<div class="viewcode-block" id="LasObject.close"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.close">[docs]</a>  <span class="k">def</span> <span class="nf">close</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Close las file and remove lock</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_lock</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_filename</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_fid</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="LasObject.filename"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.filename">[docs]</a>  <span class="k">def</span> <span class="nf">filename</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Las filename</span>

<span class="sd">      :returns: Las filename</span>
<span class="sd">      :rtype: string</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_filename</span>
</div>
<div class="viewcode-block" id="LasObject.height"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.height">[docs]</a>  <span class="k">def</span> <span class="nf">height</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Las dataset y range</span>

<span class="sd">      :returns: Las dataset y range</span>
<span class="sd">      :rtype: float</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">y0</span><span class="p">,</span> <span class="n">y1</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">yRange</span><span class="p">()</span>
    <span class="k">return</span> <span class="n">y1</span> <span class="o">-</span> <span class="n">y0</span>
</div>
<div class="viewcode-block" id="LasObject.width"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.width">[docs]</a>  <span class="k">def</span> <span class="nf">width</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return dataset x range</span>

<span class="sd">      :returns: Las dataset x range</span>
<span class="sd">      :rtype: float</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">x0</span><span class="p">,</span> <span class="n">x1</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">xRange</span><span class="p">()</span>
    <span class="k">return</span> <span class="n">x1</span> <span class="o">-</span> <span class="n">x0</span>
</div>
<div class="viewcode-block" id="LasObject.header"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.header">[docs]</a>  <span class="k">def</span> <span class="nf">header</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Las Header</span>

<span class="sd">      :returns: Las Header</span>
<span class="sd">      :rtype: :class:`~ALASpy.header.Header`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span>
</div>
<div class="viewcode-block" id="LasObject.isReadMode"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.isReadMode">[docs]</a>  <span class="k">def</span> <span class="nf">isReadMode</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return True if Las file is in &#39;read&#39; mode</span>

<span class="sd">      :returns: True if Las file is in &#39;read&#39; mode</span>
<span class="sd">      :rtype: bool</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fid</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">&#39;r&#39;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="LasObject.records"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.records">[docs]</a>  <span class="k">def</span> <span class="nf">records</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Point Data Records object</span>

<span class="sd">      :returns: Point Data Records object</span>
<span class="sd">      :rtype: :class:`~ALASpy.pointDataRecords.PointDataRecords`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_PointDataRecords</span>
</div>
<div class="viewcode-block" id="LasObject.progress"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.progress">[docs]</a>  <span class="k">def</span> <span class="nf">progress</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">info</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Must be reimplemented in derived class to get the overal point</span>
<span class="sd">        reading progress</span>

<span class="sd">      :param value: progress value in [0, 1]</span>
<span class="sd">      :type  value: float</span>
<span class="sd">      :param info: info object</span>
<span class="sd">      :type  info: any</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="n">info</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
      <span class="k">print</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s">: Progress </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">info</span><span class="p">),</span> <span class="n">value</span> <span class="o">*</span> <span class="mf">100.</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">print</span> <span class="s">&#39;Progress </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">value</span> <span class="o">*</span> <span class="mf">100.</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="LasObject.write"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.LasObject.write">[docs]</a>  <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">points</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">):</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_PointDataRecords</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">points</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">)</span>

<span class="c">#===============================================================================</span>

<span class="c"># I love Python!</span></div></div>
<span class="n">LasObject</span><span class="o">.</span><span class="n">write</span><span class="o">.</span><span class="n">__func__</span><span class="o">.</span><span class="n">__doc__</span> <span class="o">=</span> <span class="n">PointDataRecords</span><span class="o">.</span><span class="n">write</span><span class="o">.</span><span class="n">__doc__</span>
<span class="c">#===============================================================================</span>
<div class="viewcode-block" id="main"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.las.main">[docs]</a><span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
  <span class="kn">import</span> <span class="nn">sys</span>
  <span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span>
  <span class="kn">from</span> <span class="nn">header</span> <span class="kn">import</span> <span class="n">VLRecord</span>
  <span class="kn">from</span> <span class="nn">IPython</span> <span class="kn">import</span> <span class="n">embed</span>
  <span class="n">trueExcepthook</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">excepthook</span>

  <span class="k">def</span> <span class="nf">excepthook</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">traceback</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">__base__</span> <span class="ow">in</span> <span class="p">(</span><span class="n">LasException</span><span class="p">,</span> <span class="ne">IOError</span><span class="p">):</span>
      <span class="k">print</span> <span class="s">&quot;Unhandled Exception &lt;</span><span class="si">%s</span><span class="s">&gt;: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">__name__</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="n">trueExcepthook</span><span class="p">(</span><span class="nb">type</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">traceback</span><span class="p">)</span>

  <span class="n">sys</span><span class="o">.</span><span class="n">excepthook</span> <span class="o">=</span> <span class="n">excepthook</span>

  <span class="n">l</span> <span class="o">=</span> <span class="n">LasObject</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
  <span class="k">print</span> <span class="n">l</span><span class="o">.</span><span class="n">header</span><span class="p">()</span><span class="o">.</span><span class="n">prettyWkt</span><span class="p">()</span>
  <span class="c">#data = l.records().read(pointsDtype=np.array(()), fields=&#39;short&#39;, unique=True, asFloat=False, recsPerChunk=3)</span>
  <span class="n">data</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">records</span><span class="p">()</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">pointsDtype</span><span class="o">=</span><span class="s">&#39;/tmp/ccqq&#39;</span><span class="p">,</span> <span class="n">fields</span><span class="o">=</span><span class="s">&#39;short&#39;</span><span class="p">,</span> <span class="n">unique</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">asFloat</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">recsPerChunk</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
  <span class="c">#data = l.records().read(pointsDtype=dict(), recsPerChunk=3)</span>
  <span class="c">#data = l.records().read(pointsDtype=dict, recsPerChunk=3, fields=&#39;short&#39;, asFloat=True)</span>
  <span class="c">#data = l.records().read(pointsDtype=dict, fields=&#39;short&#39;, asFloat=True)</span>

  <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">filename</span><span class="p">())</span> <span class="o">==</span> <span class="s">&#39;test.las&#39;</span><span class="p">:</span>
    <span class="n">embed</span><span class="p">()</span>
    <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span>
  <span class="n">newl</span> <span class="o">=</span> <span class="n">LasObject</span><span class="p">(</span><span class="s">&#39;test.las&#39;</span><span class="p">,</span> <span class="s">&#39;w&#39;</span><span class="p">,</span> <span class="n">version</span><span class="o">=</span><span class="n">l</span><span class="o">.</span><span class="n">header</span><span class="p">()</span><span class="o">.</span><span class="n">version</span><span class="p">(),</span>
    <span class="n">pointDataFormatID</span><span class="o">=</span><span class="n">l</span><span class="o">.</span><span class="n">header</span><span class="p">()</span><span class="o">.</span><span class="n">getPointDataFormatID</span><span class="p">())</span>
  <span class="n">newHeader</span> <span class="o">=</span> <span class="n">newl</span><span class="o">.</span><span class="n">header</span><span class="p">()</span>
  <span class="n">newHeader</span><span class="o">.</span><span class="n">setWkt</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">header</span><span class="p">()</span><span class="o">.</span><span class="n">wkt</span><span class="p">())</span>
  <span class="c">#print newl.header().prettyWkt()</span>
  <span class="c"># Create new &#39;OGS&#39; VLRecord </span>
  <span class="n">payload</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">d1</span><span class="o">=</span><span class="s">&quot;Some secret data&quot;</span><span class="p">,</span> <span class="n">d2</span><span class="o">=</span><span class="s">&quot;More secret...&quot;</span><span class="p">)</span>
  <span class="n">ogs</span> <span class="o">=</span> <span class="n">VLRecord</span><span class="p">(</span><span class="n">newHeader</span><span class="p">,</span> <span class="n">VLRecord</span><span class="o">.</span><span class="n">OGS</span><span class="p">,</span> <span class="n">recordID</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
      <span class="n">description</span><span class="o">=</span><span class="s">&quot;A private VLR&quot;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">payload</span><span class="p">)</span>
  <span class="k">print</span> <span class="s">&quot;NEW ogs VLRecord:&quot;</span><span class="p">,</span> <span class="n">ogs</span>
  <span class="n">newHeader</span><span class="o">.</span><span class="n">addVarLengthRecord</span><span class="p">(</span><span class="n">ogs</span><span class="p">)</span>
  <span class="n">newl</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">offsets</span><span class="o">=</span><span class="n">l</span><span class="o">.</span><span class="n">header</span><span class="p">()</span><span class="o">.</span><span class="n">offsets</span><span class="p">())</span>
  <span class="n">embed</span><span class="p">()</span>

<span class="c">#===============================================================================</span></div>
<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&#39;__main__&#39;</span><span class="p">:</span>
  <span class="n">main</span><span class="p">()</span>
</pre></div>

          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/ogs.png" alt="Logo"/>
            </a></p>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../index.html">ALASpy 0.1.1 documentation</a> &raquo;</li>
          <li><a href="../index.html" >Module code</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Roberto Vidmar, Nicola Creati.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>